package com.spring.schedule_system.controller;

import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.fastjson.JSON;
import com.auth0.jwt.exceptions.TokenExpiredException;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.spring.schedule_system.dao.ClassroomDao;
import com.spring.schedule_system.dao.CourseDao;
import com.spring.schedule_system.dao.Schedule1Dao;
import com.spring.schedule_system.dao.TeacherDao;
import com.spring.schedule_system.dengxiaojiao.util.LyLog;
import com.spring.schedule_system.dengxiaojiao.util.LyLoggerFactory;
import com.spring.schedule_system.dengxiaojiao.util.OptResult;
import com.spring.schedule_system.entity.*;
import com.spring.schedule_system.utils.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;

@CrossOrigin
@Controller
@RequestMapping("/classroom")
@Api(value = "ClassroomController", description = "教室相关api")
public class ClassroomController {

    private static final Logger log = LoggerFactory.getLogger(ClassroomController.class);

    Boolean flag;
    MyUtil myUtil = new MyUtil();
    @Autowired(required = false)
    private ClassroomDao classroomDao;
    @Autowired
    private Schedule1Dao schedule1Dao;
    @Autowired
    CarDeliveryAppService carDeliveryAppService;

    /**
     * 导入教室信息
     *
     * @param noticeFiles
     * @return
     * @throws IOException
     */
    @ApiOperation("导入教室")
    @PostMapping("/web/importClassroomExcel")
    @ResponseBody
    public ResponseEntity importClassroomExcel(MultipartFile noticeFiles) throws IOException {
        ResponseEntity responseData;
        Workbook workbook = null;
        String fileName = noticeFiles.getOriginalFilename();
        if (fileName.endsWith("xls")) {
            workbook = new HSSFWorkbook(noticeFiles.getInputStream());
        } else if (fileName.endsWith("xlsx")) {
            workbook = new XSSFWorkbook(noticeFiles.getInputStream());
        } else {
            throw new IOException("文件不是Excel类型");
        }
        Sheet sheet = workbook.getSheet("机房信息");
        int rows = sheet.getLastRowNum();
        if (rows == 0) {
            throw new IOException("没有数据导入失败");
        }
        for (int i = 1; i < rows + 1; i++) {
            Row row = sheet.getRow(i);
            if (row != null) {
                Classroom classroom = new Classroom();
                MyUtil myUtil = new MyUtil();
                String classroom_address = myUtil.getCellValue(row.getCell(0));
                classroom.setClassroom_address(classroom_address);
                String classroom_name = myUtil.getCellValue(row.getCell(1));
                classroom.setClassroom_name(classroom_name);
                Integer classroom_count = Integer.parseInt(myUtil.getCellValue(row.getCell(2)));
                classroom.setClassroom_count(classroom_count);
                String classroom_attribute = myUtil.getCellValue(row.getCell(3));
                classroom.setClassroom_attribute(classroom_attribute);
                String classroom_remarks = myUtil.getCellValue(row.getCell(4));
                classroom.setClassroom_remarks(classroom_remarks);
                classroomDao.insert(classroom);
            }
        }
        responseData = ResponseEntity.ok();
        responseData.putDataValue("msg", "导入成功");

        return responseData;
    }

    /**
     * 添加教室
     *
     * @param classroom_address
     * @param classroom_name
     * @param classroom_count
     * @param classroom_remarks
     * @param classroom_attribute
     * @param Authorization
     * @return
     * @throws IOException
     * @throws TokenExpiredException
     */
    @ApiOperation("添加教室")
    @PostMapping("/web/addClassroom")
    @ResponseBody
    public ResponseEntity addClassroom(@RequestParam(required = true) String classroom_address,
                                       @RequestParam(required = true) String classroom_name,
                                       @RequestParam(required = true) Integer classroom_count,
                                       @RequestParam(required = false) String classroom_remarks,
                                       @RequestParam(required = false) String classroom_attribute,
                                       @RequestHeader String Authorization) throws IOException, TokenExpiredException {
        ResponseEntity responseEntity;
        String token = Authorization;
        //判断token是否存在或过期
        if (flag = myUtil.judgeToken(token)) {
            responseEntity = ResponseEntity.forbidden();
            responseEntity.putDataValue("msg", "token不存在或已过期");
            return responseEntity;
        }
        User user = JwtToken.unsign(token, User.class);
        //用户角色，分微信用户和老师用户，1代表微信用户，2代表老师用户,默认为微信用户
        if (user.getUser_role() != 2) {
            responseEntity = ResponseEntity.unauthorized();
            responseEntity.putDataValue("msg", "权限错误");
            responseEntity.putDataValue("timestamp", myUtil.getTime());
            return responseEntity;
        }
        //根据user_jobNumber查询数据库是否有该用户存在，不存在则注册，存在则注册失败
        QueryWrapper<Classroom> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("classroom_name", classroom_name);
        Classroom classroom = classroomDao.selectOne(queryWrapper);
        //User userFromBase = userDao.selectById(user_name);
        if (classroom == null) {
            responseEntity = ResponseEntity.ok();
            Classroom classroom1 = new Classroom();
            classroom1.setClassroom_address(classroom_address);
            classroom1.setClassroom_name(classroom_name);
            classroom1.setClassroom_count(classroom_count);
            classroom1.setClassroom_remarks(classroom_remarks);
            classroom1.setClassroom_attribute(classroom_attribute);
            Integer classroom_status = 0;
            classroom1.setClassroom_status(classroom_status);
            classroomDao.insert(classroom1);
            responseEntity.putDataValue("classroom_id", classroom1.getClassroom_id());
            responseEntity.putDataValue("classroom_name", classroom1.getClassroom_name());
            responseEntity.putDataValue("msg", "教室注册成功");
        } else {
            responseEntity = ResponseEntity.badRequest();
            responseEntity.putDataValue("msg", "教室注册失败");
        }
        return responseEntity;
    }

    /**
     * 修改教室信息
     *
     * @param classroom_id
     * @param classroom_address
     * @param classroom_name
     * @param classroom_count
     * @param classroom_remarks
     * @param classroom_attribute
     * @param classroom_status
     * @param Authorization
     * @return
     * @throws IOException
     */
    @ApiOperation("修改教室信息")
    @PutMapping("/web/updateClassroom")
    @ResponseBody
    public ResponseEntity updateClassroom(@RequestParam(required = true) int classroom_id,
                                          @RequestParam(required = false) String classroom_address,
                                          @RequestParam(required = false) String classroom_name,
                                          @RequestParam(required = false) Integer classroom_count,
                                          @RequestParam(required = false) String classroom_remarks,
                                          @RequestParam(required = false) String classroom_attribute,
                                          @RequestParam(required = false) Integer classroom_status,
                                          @RequestHeader String Authorization) throws IOException {
        ResponseEntity responseEntity;
        String token = Authorization;
        if (flag = myUtil.judgeToken(token)) {
            responseEntity = ResponseEntity.forbidden();
            responseEntity.putDataValue("msg", "token不存在或已过期");
            return responseEntity;
        }
        User users = JwtToken.unsign(token, User.class);
        if (users == null) {
            responseEntity = ResponseEntity.notFound();
            responseEntity.putDataValue("msg", "用户不存在");
            return responseEntity;
        } else if (users.getUser_role() != 2) {
            responseEntity = ResponseEntity.unauthorized();
            responseEntity.putDataValue("msg", "没有权限");
            return responseEntity;

        } else {
            responseEntity = ResponseEntity.ok();
            Classroom classroom = classroomDao.selectById(classroom_id);
            classroom.setClassroom_address(classroom_address);
            classroom.setClassroom_name(classroom_name);
            classroom.setClassroom_count(classroom_count);
            classroom.setClassroom_remarks(classroom_remarks);
            classroom.setClassroom_attribute(classroom_attribute);
            classroom.setClassroom_status(classroom_status);
            classroomDao.updateById(classroom);
            responseEntity.putDataValue("msg", "教室修改成功");
            return responseEntity;
        }
    }

    /**
     * 根据classroom_id查询教室
     *
     * @param classroom_id
     * @param Authorization
     * @return
     * @throws IOException
     */
    @ApiOperation("根据classroom_id查询教室")
    @PutMapping("/web/selectByClassroomId")
    @ResponseBody
    public ResponseEntity selectByClassroomId(@RequestParam(required = true) Integer classroom_id,
                                              @RequestHeader String Authorization) throws IOException {
        ResponseEntity responseEntity;
        String token = Authorization;
        if (flag = myUtil.judgeToken(token)) {
            responseEntity = ResponseEntity.forbidden();
            responseEntity.putDataValue("msg", "token不存在或已过期");
            return responseEntity;
        }
        User users = JwtToken.unsign(token, User.class);
        if (users == null) {
            responseEntity = ResponseEntity.notFound();
            responseEntity.putDataValue("msg", "用户不存在");
            return responseEntity;
        }
        responseEntity = ResponseEntity.ok();
        Classroom classroom = classroomDao.selectById(classroom_id);
        if (classroom == null) {
            responseEntity = ResponseEntity.badRequest();
            responseEntity.putDataValue("msg", "查询的教室不存在");
            return responseEntity;
        }
        responseEntity.putDataValue("classroom", classroom);
        return responseEntity;
    }

    /**
     * 根据classroom_address查询教室
     *
     * @param classroom_address
     * @param Authorization
     * @return
     * @throws IOException
     */
    @ApiOperation("根据classroom_address查询教室")
    @PutMapping("/web/selectByClassroomAddress")
    @ResponseBody
    public ResponseEntity selectByClassroomAddress(@RequestParam(required = true) String classroom_address,
                                                   @RequestHeader String Authorization) throws IOException {
        ResponseEntity responseEntity;
        String token = Authorization;
        if (flag = myUtil.judgeToken(token)) {
            responseEntity = ResponseEntity.forbidden();
            responseEntity.putDataValue("msg", "token不存在或已过期");
            return responseEntity;
        }
        DateTimeFormatter dfDate = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
        String format = dfDate.format(LocalDateTime.now());
        User users = JwtToken.unsign(token, User.class);
        if (users == null) {
            responseEntity = ResponseEntity.notFound();
            responseEntity.putDataValue("msg", "用户不存在");
            return responseEntity;
        }
        responseEntity = ResponseEntity.ok();
        QueryWrapper<Classroom> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("classroom_address", classroom_address);
        Classroom classroom = classroomDao.selectOne(queryWrapper);
        if (classroom == null) {
            responseEntity = ResponseEntity.badRequest();
            responseEntity.putDataValue("msg", "查询的教室不存在");
            return responseEntity;
        }
        responseEntity.putDataValue("classroom", classroom);
        return responseEntity;
    }


    /**
     * 根据classroom_id删除教室信息
     *
     * @param classroom_id
     * @param Authorization
     * @return
     * @throws IOException
     */
    @ApiOperation("根据classroom_id删除教室信息")
    @PutMapping("/web/deleteClassroom")
    @ResponseBody
    public ResponseEntity deleteClassroom(@RequestParam(required = true) Integer classroom_id,
                                          @RequestHeader String Authorization) throws IOException {
        ResponseEntity responseEntity;
        String token = Authorization;
        if (flag = myUtil.judgeToken(token)) {
            responseEntity = ResponseEntity.forbidden();
            responseEntity.putDataValue("msg", "token不存在或已过期");
            return responseEntity;
        }
        User users = JwtToken.unsign(token, User.class);
        if (users == null) {
            responseEntity = ResponseEntity.notFound();
            responseEntity.putDataValue("msg", "用户不存在");
            return responseEntity;
        } else if (users.getUser_role() == 2) {
            Classroom classroom = classroomDao.selectById(classroom_id);
            if (classroom != null) {
                classroomDao.deleteById(classroom_id);
                responseEntity = ResponseEntity.ok();
                responseEntity.putDataValue("msg", "删除成功");
                return responseEntity;
            } else {
                responseEntity = ResponseEntity.badRequest();
                responseEntity.putDataValue("msg", "删除的教室已经不存在");
            }
        }
        responseEntity = ResponseEntity.unauthorized();
        responseEntity.putDataValue("msg", "没有权限");
        return responseEntity;
    }

    /**
     * 根据classroom_address删除教室信息
     *
     * @param classroom_address
     * @param Authorization
     * @return
     * @throws IOException
     */
    @ApiOperation("根据classroom_address删除教室信息")
    @PutMapping("/web/deleteClassroomByClassroomAddress")
    @ResponseBody
    public ResponseEntity deleteClassroomByClassroomAddress(@RequestParam(required = true) String classroom_address,
                                                            @RequestHeader String Authorization) throws IOException {
        ResponseEntity responseEntity;
        String token = Authorization;
        if (flag = myUtil.judgeToken(token)) {
            responseEntity = ResponseEntity.forbidden();
            responseEntity.putDataValue("msg", "token不存在或已过期");
            return responseEntity;
        }
        User users = JwtToken.unsign(token, User.class);
        if (users == null) {
            responseEntity = ResponseEntity.notFound();
            responseEntity.putDataValue("msg", "用户不存在");
            return responseEntity;
        } else if (users.getUser_role() == 2) {
            QueryWrapper<Classroom> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("classroom_address", classroom_address);
            Classroom classroom = classroomDao.selectOne(queryWrapper);
            if (classroom != null) {
                QueryWrapper<Classroom> queryWrapper1 = new QueryWrapper<>();
                queryWrapper1.eq("classroom_address", classroom_address);
                classroomDao.delete(queryWrapper1);
                responseEntity = ResponseEntity.ok();
                responseEntity.putDataValue("msg", "删除成功");
                return responseEntity;
            } else {
                responseEntity = ResponseEntity.badRequest();
                responseEntity.putDataValue("msg", "删除的课室已经不存在");
                return responseEntity;
            }
        }
        responseEntity = ResponseEntity.unauthorized();
        responseEntity.putDataValue("msg", "没有权限");
        return responseEntity;
    }


    /**
     * 教室列表
     *
     * @param Authorization
     * @param response
     * @return
     * @throws IOException
     */
    @ApiOperation("教室列表")
    @PostMapping("/web/classroomList")
    @ResponseBody
    public ResponseEntity classroomList(@RequestHeader String Authorization,
                                        HttpServletResponse response) throws IOException {
        response.setHeader("Access-Control-Allow-Origin", "*");
        /*星号表示所有的域都可以接受，*/
        response.setHeader("Access-Control-Allow-Methods", "GET,POST");

        ResponseEntity responseData;
        String token = Authorization;
        //通过token解密出来的user对象
        User user = JwtToken.unsign(token, User.class);
        //判断token是否存在或过期
        if (flag = myUtil.judgeToken(token)) {
            responseData = ResponseEntity.forbidden();
            responseData.putDataValue("msg", "token不存在或已过期");
            return responseData;
        }
        QueryWrapper<Classroom> wrapper = new QueryWrapper<>();
        List<Classroom> list = classroomDao.selectList(wrapper);
        if (list == null) {
            responseData = ResponseEntity.badRequest();
            responseData.putDataValue("msg", "查询的教室不存在");
            return responseData;
        }
        responseData = ResponseEntity.ok();
        responseData.putDataValue("classroom", list);
        responseData.putDataValue("msg", "成功");
        return responseData;
    }

    /**
     * 统计教室数量
     */
    @ApiOperation("统计教室数量")
    @GetMapping("/web/count")
    @ResponseBody
    public ResponseEntity count() throws IOException {
        ResponseEntity responseData;
        int count = classroomDao.selectCount(null);
        responseData = ResponseEntity.ok();
        responseData.putDataValue("count", count);
        return responseData;
    }

    /**
     * 根据classroom_id批量删除教室
     *
     * @param arr
     * @param Authorization
     * @return
     */
    @ApiOperation("根据classroom_id批量删除教室")
    @GetMapping("/web/deleteClassroomList")
    @ResponseBody
    public ResponseEntity deleteClassroomList(@RequestParam(required = true) int[] arr,
                                              @RequestHeader String Authorization) throws IOException {
        ResponseEntity responseData;
        String token = Authorization;
        //通过token解密出来的user对象
        User user = JwtToken.unsign(token, User.class);
        //判断token是否存在或过期
        if (flag = myUtil.judgeToken(token)) {
            responseData = ResponseEntity.forbidden();
            responseData.putDataValue("msg", "token不存在或已过期");
            return responseData;
        }
        if (user.getUser_role() != 2) {
            responseData = ResponseEntity.badRequest();
            responseData.putDataValue("msg", "权限错误");
            responseData.putDataValue("timestamp", myUtil.getTime());
            return responseData;
        }
        for (int classroom_id : arr) {
            Classroom classroom = classroomDao.selectById(classroom_id);
            if (classroom != null) {
                classroomDao.deleteById(classroom_id);
            }
        }
        responseData = ResponseEntity.ok();
        responseData.putDataValue("msg", "批量删除数据成功");
        return responseData;
    }

    /**
     * 根据classroom_address批量删除教室
     *
     * @param arr
     * @param Authorization
     * @return
     */
    @ApiOperation("根据classroom_address批量删除教室")
    @GetMapping("/web/deleteClassroomListByClassroomAddress")
    @ResponseBody
    public ResponseEntity deleteClassroomListByClassroomAddress(@RequestParam(required = true) String[] arr,
                                                                @RequestHeader String Authorization) throws IOException {
        ResponseEntity responseData;
        String token = Authorization;
        //通过token解密出来的user对象
        User user = JwtToken.unsign(token, User.class);
        //判断token是否存在或过期
        if (flag = myUtil.judgeToken(token)) {
            responseData = ResponseEntity.forbidden();
            responseData.putDataValue("msg", "token不存在或已过期");
            return responseData;
        }
        if (user.getUser_role() != 2) {
            responseData = ResponseEntity.badRequest();
            responseData.putDataValue("msg", "权限错误");
            responseData.putDataValue("timestamp", myUtil.getTime());
            return responseData;
        }
        for (String classroom_address : arr) {
            QueryWrapper<Classroom> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("classroom_address", classroom_address);
            Classroom classroom = classroomDao.selectOne(queryWrapper);
            if (classroom != null) {
                QueryWrapper<Classroom> queryWrapper1 = new QueryWrapper<>();
                queryWrapper1.eq("classroom_address", classroom_address);
                classroomDao.delete(queryWrapper1);

            }
        }
        responseData = ResponseEntity.ok();
        responseData.putDataValue("msg", "批量删除数据成功");
        return responseData;

    }

    /**
     * 根据classroom_address模糊查询班级
     *
     * @param classroom_address
     * @param Authorization
     * @return
     * @throws IOException
     */
    @ApiOperation("根据classroom_address模糊查询班级")
    @PutMapping("/web/selectByLikeClassroomAddress")
    @ResponseBody
    public ResponseEntity selectByLikeClassroomAddress(@RequestParam(required = true) String classroom_address, @RequestHeader String Authorization) throws IOException {
        ResponseEntity responseEntity;
        String token = Authorization;
        if (flag = myUtil.judgeToken(token)) {
            responseEntity = ResponseEntity.forbidden();
            responseEntity.putDataValue("msg", "token不存在或已过期");
            return responseEntity;
        }
        User users = JwtToken.unsign(token, User.class);
        if (users == null) {
            responseEntity = ResponseEntity.notFound();
            responseEntity.putDataValue("msg", "用户不存在");
            return responseEntity;
        }
        responseEntity = ResponseEntity.ok();
        QueryWrapper<Classroom> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("classroom_address", classroom_address);
        List<Classroom> classrooms = classroomDao.selectList(queryWrapper);
        if (classrooms == null) {
            responseEntity = ResponseEntity.badRequest();
            responseEntity.putDataValue("msg", "查询的教室不存在");
            return responseEntity;
        }
        responseEntity.putDataValue("classrooms", classrooms);
        return responseEntity;

    }

    /**
     * 导出教室2
     *
     * @param response
     * @return
     */
    @ApiOperation("导出教室（测试）")
    @PostMapping("/web/exportClassroom2")
    @ResponseBody
    public ResponseEntity exportClassroom2(HttpServletResponse response) throws IOException {
//        QueryWrapper<Classroom> queryWrapper = new QueryWrapper<>();
        List<Classroom> list = classroomDao.selectList(null);
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        ExcelWriterBO excelWriterBO = ExcelUtil.writeExcelBO(outputStream);
        WriteSheet writeSheet = excelWriterBO.createSheet("课室", Classroom.class);
        excelWriterBO.write(list, writeSheet);
        excelWriterBO.finish();
        byte[] bytes = outputStream.toByteArray();
        outputStream.close();
        ResponseEntity responseEntity;
        responseEntity = ResponseEntity.ok();
        responseEntity.putDataValue("msg", "导出成功");
        return responseEntity;
    }

    /**
     * 导出教室
     *
     * @param response
     * @return
     * @throws IOException
     */
    @ApiOperation("导出教室")
    @PostMapping("/web/exportClassroom")
    @ResponseBody
    public ResponseEntity exportClassroom(HttpServletResponse response) throws IOException {
        ResponseEntity responseEntity;
        responseEntity = ResponseEntity.ok();
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet("Sheet1");
        HSSFRow row = sheet.createRow(0);
        HSSFCellStyle style = wb.createCellStyle();
        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
        HSSFCell cell = row.createCell(0);
        cell.setCellValue("教室地点");
        cell.setCellStyle(style);
        cell = row.createCell(1);
        cell.setCellValue("教室名称");
        cell.setCellStyle(style);
        cell = row.createCell(2);
        cell.setCellValue("可容纳机位");
        cell.setCellStyle(style);
        cell = row.createCell(3);
        cell.setCellValue("备注");
        cell.setCellStyle(style);
        cell = row.createCell(4);
        cell.setCellValue("属性");
        cell.setCellStyle(style);

        QueryWrapper<Classroom> queryWrapper = new QueryWrapper<>();
        List<Classroom> list = classroomDao.selectList(queryWrapper);
        for (int i = 0; i < list.size(); i++) {
            row = sheet.createRow(i + 1);
            Classroom classroom = list.get(i);
            row.createCell(0).setCellValue(classroom.getClassroom_address());
            row.createCell(1).setCellValue(classroom.getClassroom_name());
            row.createCell(2).setCellValue(classroom.getClassroom_count());
            row.createCell(3).setCellValue(classroom.getClassroom_remarks());
            row.createCell(4).setCellValue(classroom.getClassroom_attribute());

        }
        long filename = System.currentTimeMillis();
        SimpleDateFormat df = new SimpleDateFormat("yyMMddHHmmss");
        String fileName = df.format(new Date());
        response.setContentType("application/msexcel");
        response.setHeader("Content-disposition", "attachment; filename=" + fileName + ".xls");
        response.flushBuffer();
        wb.write(response.getOutputStream());
        responseEntity.putDataValue("msg", "导出成功");
        return responseEntity;
    }

    /**
     * 查询某周星期几的课室列表（分空闲和不空闲）
     *
     * @param class_weeks
     * @param weeks
     * @param number_sections
     * @return
     */
    @ApiOperation("查询某周星期几的课室列表（分空闲和不空闲）")
    @PostMapping("/web/selectDayOpenClassroom")
    @ResponseBody
    public ResponseEntity selectDayOpenClassroom(@RequestParam(required = true, defaultValue = "2") String class_weeks, @RequestParam(required = true, defaultValue = "二") String weeks, @RequestParam(required = true, defaultValue = "1、2") String number_sections) {
        ResponseEntity responseData;
        responseData = ResponseEntity.ok();
        List<Classroom> freeRoomList = classroomDao.selectClassRoomList(class_weeks, weeks, number_sections);
        List<Classroom> noEmptyRoomList = classroomDao.selectRoomListKongXian(class_weeks, weeks, number_sections);
        Map<String, List<Classroom>> map = new HashMap<>();
        map.put("freeRoomList", freeRoomList);
        map.put("noEmptyRoomList", noEmptyRoomList);
        responseData.putDataValue("map", map);
        return responseData;
    }

    @ApiOperation(value = "保存交车", notes = "保存交车")
    @RequestMapping(value = "venBuDeliveryOrderSave", method = RequestMethod.POST)
    public OptResult venBuDeliveryOrderSave(@RequestBody(required = true) @Valid Map<String, Object> map) {
        log.info("【venBuDeliveryOrderAndPreDeliveryOrderSaveRequest"   + JSON.toJSONString(map));


        //<editor-fold desc="正式交车需检校PDI">
        //</editor-fold>

        //<editor-fold desc="是否重复提交配置 VE0799 交车作业是否重复提交配置">

        //</editor-fold>


        //<editor-fold desc="正式交车需三要素校验及机动车发票校验">
        //1、一般销售订单 2、二级网点 3、调拨销售 4、代PV大客户交车 5、本店大客户(异店交车) 6、本店大客户(本店交车) 7、代异店交车

        //</editor-fold>


        //<editor-fold desc="正式交车需校验是否存在红票（机动车和增值税）没有匹配的，存在没有匹配的红票不能交车 2024-07-23">

        //</editor-fold>


        return carDeliveryAppService.venBuDeliveryOrderSave(map);
    }


}
